package Clases;

import java.awt.Frame;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AsignarSeccion.java
 *
 * Created on 16/02/2011, 09:09:34 AM
 */
/**
 *
 * @author Mariant
 */
public class AsignarSeccion extends javax.swing.JFrame {

    /** Creates new form AsignarSeccion */
    public AsignarSeccion() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtas = new javax.swing.JTextField();
        btnGuardar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Asignar Seccion");
        setAlwaysOnTop(true);
        getContentPane().setLayout(null);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("Numero de seccion:");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(70, 80, 140, 40);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel2.setText("Asignar Seccion");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(170, 20, 140, 30);
        getContentPane().add(txtas);
        txtas.setBounds(70, 130, 140, 40);

        btnGuardar.setBackground(new java.awt.Color(0, 204, 204));
        btnGuardar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnGuardar.setText("Guardar");
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });
        getContentPane().add(btnGuardar);
        btnGuardar.setBounds(250, 130, 110, 40);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-426)/2, (screenSize.height-306)/2, 426, 306);
    }// </editor-fold>//GEN-END:initComponents

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        // TODO add your handling code here:
        if (!txtas.getText().isEmpty()) {
            try {
                int x = Integer.parseInt(txtas.getText());
                Seccion sec = new Seccion(btnGuardar.getText());
                Menu.setSec(sec);
                Menu.setVariableSeccion(true);
                dispose();
            } catch (NumberFormatException e) { //y esto valido
                JOptionPane.showMessageDialog(new Frame(), "Error debe ser un numero");
            }
        } else {
            JOptionPane.showMessageDialog(new Frame(), "Campo vacio, verifique", "validacion", JOptionPane.INFORMATION_MESSAGE);
        }




    }//GEN-LAST:event_btnGuardarActionPerformed
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AsignarSeccion().setVisible(true);


            }
        });


    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnGuardar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField txtas;
    // End of variables declaration//GEN-END:variables
}
